//
//  shopCell.m
//  UI_HLJ_Frame
//
//  Created by dlios on 15-7-6.
//  Copyright (c) 2015年 毕宏伟. All rights reserved.
//

#import "shopCell.h"
#import "shopTableViewCell.h"
#import "shopModel.h"
#import "UIImageView+WebCache.h"


@implementation shopCell


- (instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    if (self) {
        self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height -133) style:UITableViewStylePlain];
//        self.tableView.delegate = self;
        self.tableView.dataSource = self;
        [self addSubview:self.tableView];
        self.tableView.rowHeight = 100;
        [_tableView release];

    }
    return self;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (self.flag == 0) {
        return self.arrShop.count;
    } else if (self.flag == 1){
        return self.arrShop1.count;
    } else if (self.flag == 2){
        return self.arrShop2.count;
    } else if (self.flag == 3){
        return self.arrShop3.count;
    } else if (self.flag == 4){
        return self.arrShop4.count;
    } else {
        return self.arrShop5.count;
    }
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString *reuse = @"reuse";
    shopTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse];
    if (!cell) {
        cell = [[[shopTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuse]autorelease];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
#pragma mark 传值
    if (self.flag == 0) {
        
    shopModel *model = self.arrShop[indexPath.row];
    
    
    // 传标题
    cell.labelBT.text = model.name;
    cell.labelBT.font = [UIFont systemFontOfSize:14];
    
    // 传图片
           [cell.ImageView sd_setImageWithURL:[NSURL URLWithString:model.logo_path] placeholderImage:[UIImage imageNamed:@"占位图"]];
//    [cell.ImageView sd_setImageWithURL:[NSURL URLWithString:model.logo_path]];
        
    // 传套餐
    CGFloat active_cases_pcount1 = [model.active_works_pcount floatValue];
    NSString *active_cases_pcount = [NSString stringWithFormat:@"套餐 %.0f", active_cases_pcount1];
    cell.labelTC.text = active_cases_pcount;
    cell.labelTC.font = [UIFont systemFontOfSize:12];
    
    // 传案例
    CGFloat active_works_pcount1 = [model.active_cases_pcount floatValue];
    NSString *active_works_pcount = [NSString stringWithFormat:@"案例 %.0f", active_works_pcount1];
    cell.labelAL.text = active_works_pcount;
    cell.labelAL.font = [UIFont systemFontOfSize:12];
    
    // 传粉丝
    CGFloat fans_count1 = [model.fans_count floatValue];
    NSString *fans_count = [NSString stringWithFormat:@"粉丝 %.0f", fans_count1];
    cell.labelGZ.text = fans_count;
    cell.labelGZ.font = [UIFont systemFontOfSize:12];

    } else if (self.flag == 1){
        
        shopModel *model1 = self.arrShop1[indexPath.row];
        
        
        // 传标题
        cell.labelBT.text = model1.name;
        cell.labelBT.font = [UIFont systemFontOfSize:14];
        
        // 传图片
            [cell.ImageView sd_setImageWithURL:[NSURL URLWithString:model1.logo_path] placeholderImage:[UIImage imageNamed:@"占位图"]];
//        [cell.ImageView sd_setImageWithURL:[NSURL URLWithString:model1.logo_path]];
        
        // 传套餐
        CGFloat active_cases_pcount1 = [model1.active_works_pcount floatValue];
        NSString *active_cases_pcount = [NSString stringWithFormat:@"套餐 %.0f", active_cases_pcount1];
        cell.labelTC.text = active_cases_pcount;
        cell.labelTC.font = [UIFont systemFontOfSize:12];
        
        // 传案例
        CGFloat active_works_pcount1 = [model1.active_cases_pcount floatValue];
        NSString *active_works_pcount = [NSString stringWithFormat:@"案例 %.0f", active_works_pcount1];
        cell.labelAL.text = active_works_pcount;
        cell.labelAL.font = [UIFont systemFontOfSize:12];
        
        // 传粉丝
        CGFloat fans_count1 = [model1.fans_count floatValue];
        NSString *fans_count = [NSString stringWithFormat:@"粉丝 %.0f", fans_count1];
        cell.labelGZ.text = fans_count;
        cell.labelGZ.font = [UIFont systemFontOfSize:12];
        
    } else if (self.flag == 2){
        
        shopModel *model2 = self.arrShop2[indexPath.row];
        
        // 传标题
        cell.labelBT.text = model2.name;
        cell.labelBT.font = [UIFont systemFontOfSize:14];
        
        // 传图片
            [cell.ImageView sd_setImageWithURL:[NSURL URLWithString:model2.logo_path] placeholderImage:[UIImage imageNamed:@"占位图"]];
//        [cell.ImageView sd_setImageWithURL:[NSURL URLWithString:model2.logo_path]];
        
        // 传套餐
        CGFloat active_cases_pcount1 = [model2.active_works_pcount floatValue];
        NSString *active_cases_pcount = [NSString stringWithFormat:@"套餐 %.0f", active_cases_pcount1];
        cell.labelTC.text = active_cases_pcount;
        cell.labelTC.font = [UIFont systemFontOfSize:12];
        
        // 传案例
        CGFloat active_works_pcount1 = [model2.active_cases_pcount floatValue];
        NSString *active_works_pcount = [NSString stringWithFormat:@"案例 %.0f", active_works_pcount1];
        cell.labelAL.text = active_works_pcount;
        cell.labelAL.font = [UIFont systemFontOfSize:12];
        
        // 传粉丝
        CGFloat fans_count1 = [model2.fans_count floatValue];
        NSString *fans_count = [NSString stringWithFormat:@"粉丝 %.0f", fans_count1];
        cell.labelGZ.text = fans_count;
        cell.labelGZ.font = [UIFont systemFontOfSize:12];

    } else if (self.flag == 3){
        
        shopModel *model3 = self.arrShop3[indexPath.row];
        
        // 传标题
        cell.labelBT.text = model3.name;
        cell.labelBT.font = [UIFont systemFontOfSize:14];
        
        // 传图片
            [cell.ImageView sd_setImageWithURL:[NSURL URLWithString:model3.logo_path] placeholderImage:[UIImage imageNamed:@"占位图"]];
//        [cell.ImageView sd_setImageWithURL:[NSURL URLWithString:model3.logo_path]];
        
        // 传套餐
        CGFloat active_cases_pcount1 = [model3.active_works_pcount floatValue];
        NSString *active_cases_pcount = [NSString stringWithFormat:@"套餐 %.0f", active_cases_pcount1];
        cell.labelTC.text = active_cases_pcount;
        cell.labelTC.font = [UIFont systemFontOfSize:12];
        
        // 传案例
        CGFloat active_works_pcount1 = [model3.active_cases_pcount floatValue];
        NSString *active_works_pcount = [NSString stringWithFormat:@"案例 %.0f", active_works_pcount1];
        cell.labelAL.text = active_works_pcount;
        cell.labelAL.font = [UIFont systemFontOfSize:12];
        
        // 传粉丝
        CGFloat fans_count1 = [model3.fans_count floatValue];
        NSString *fans_count = [NSString stringWithFormat:@"粉丝 %.0f", fans_count1];
        cell.labelGZ.text = fans_count;
        cell.labelGZ.font = [UIFont systemFontOfSize:12];

    } else if (self.flag == 4){
        
        shopModel *model4 = self.arrShop4[indexPath.row];
        
        // 传标题
        cell.labelBT.text = model4.name;
        cell.labelBT.font = [UIFont systemFontOfSize:14];
        
        // 传图片
            [cell.ImageView sd_setImageWithURL:[NSURL URLWithString:model4.logo_path] placeholderImage:[UIImage imageNamed:@"占位图"]];
//        [cell.ImageView sd_setImageWithURL:[NSURL URLWithString:model4.logo_path]];
        
        // 传套餐
        CGFloat active_cases_pcount1 = [model4.active_works_pcount floatValue];
        NSString *active_cases_pcount = [NSString stringWithFormat:@"套餐 %.0f", active_cases_pcount1];
        cell.labelTC.text = active_cases_pcount;
        cell.labelTC.font = [UIFont systemFontOfSize:12];
        
        // 传案例
        CGFloat active_works_pcount1 = [model4.active_cases_pcount floatValue];
        NSString *active_works_pcount = [NSString stringWithFormat:@"案例 %.0f", active_works_pcount1];
        cell.labelAL.text = active_works_pcount;
        cell.labelAL.font = [UIFont systemFontOfSize:12];
        
        // 传粉丝
        CGFloat fans_count1 = [model4.fans_count floatValue];
        NSString *fans_count = [NSString stringWithFormat:@"粉丝 %.0f", fans_count1];
        cell.labelGZ.text = fans_count;
        cell.labelGZ.font = [UIFont systemFontOfSize:12];

    } else if (self.flag == 5){
        
        shopModel *model5 = self.arrShop5[indexPath.row];
        
        // 传标题
        cell.labelBT.text = model5.name;
        cell.labelBT.font = [UIFont systemFontOfSize:14];
        
        // 传图片
        
            [cell.ImageView sd_setImageWithURL:[NSURL URLWithString:model5.logo_path] placeholderImage:[UIImage imageNamed:@"占位图"]];
//        [cell.ImageView sd_setImageWithURL:[NSURL URLWithString:model5.logo_path]];
        
        // 传套餐
        CGFloat active_cases_pcount1 = [model5.active_works_pcount floatValue];
        NSString *active_cases_pcount = [NSString stringWithFormat:@"套餐 %.0f", active_cases_pcount1];
        cell.labelTC.text = active_cases_pcount;
        cell.labelTC.font = [UIFont systemFontOfSize:12];
        
        // 传案例
        CGFloat active_works_pcount1 = [model5.active_cases_pcount floatValue];
        NSString *active_works_pcount = [NSString stringWithFormat:@"案例 %.0f", active_works_pcount1];
        cell.labelAL.text = active_works_pcount;
        cell.labelAL.font = [UIFont systemFontOfSize:12];
        
        // 传粉丝
        CGFloat fans_count1 = [model5.fans_count floatValue];
        NSString *fans_count = [NSString stringWithFormat:@"粉丝 %.0f", fans_count1];
        cell.labelGZ.text = fans_count;
        cell.labelGZ.font = [UIFont systemFontOfSize:12];

    }
    return cell;
}


#pragma mark set方法
- (void)setArrShop:(NSMutableArray *)arrShop{
    
    if (_arrShop != arrShop) {
        [_arrShop release];
        _arrShop = [arrShop retain];
    }
    [self.tableView reloadData];
}

- (void)setArrShop1:(NSMutableArray *)arrShop1{
    if (_arrShop1 != arrShop1) {
        [_arrShop1 release];
        _arrShop1 = [arrShop1 retain];
    }
    [self.tableView reloadData];
}

- (void)setArrShop2:(NSMutableArray *)arrShop2{
    if (_arrShop2 != arrShop2) {
        [_arrShop2 release];
        _arrShop2 = [arrShop2 retain];
    }
    [self.tableView reloadData];
}

- (void)setArrShop3:(NSMutableArray *)arrShop3{
    if (_arrShop3 != arrShop3) {
        [_arrShop3 release];
        _arrShop3 = [arrShop3 retain];
    }
    [self.tableView reloadData];
}

- (void)setArrShop4:(NSMutableArray *)arrShop4{
    
    if (_arrShop4 != arrShop4) {
        [_arrShop4 release];
        _arrShop4 = [arrShop4 retain];
    }
    [self.tableView reloadData];
}

- (void)setArrShop5:(NSMutableArray *)arrShop5{
    
    if (_arrShop5 != arrShop5) {
        [_arrShop5 release];
        _arrShop5 = [arrShop5 retain];
    }
    [self.tableView reloadData];
}

#pragma mark tableView的点击方法



@end
